package ch6.test;

public class Student {

	private String name;
	private String num;
	private int grade;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getNum() {
		return num;
	}

	public void setNum(String num) {
		this.num = num;
	}

	public int getGrade() {
		return grade;
	}

	public void setGrade(int grade) {
		this.grade = grade;
	}

	public Student(String name, String num, int grade) {
		this.name = name;
		this.num = num;
		this.grade = grade;
	}

	public Student() {

	}

	public void sortBygrade(Student[] students) {
		int max = students[0].grade;
		for (int i = 0; i < students.length; i++) {
			for (int j = 0; j < students.length; j++) {
				if (students[i].getGrade() > students[j].getGrade()) {
					Student b = students[i];
					students[i] = students[j];
					students[j] = b;
				}
			}
		}
		System.out.println("按成绩排序后的结果如下:");
		for (int i = 0; i < students.length; i++) {
			System.out.print(students[i].getName() + " " + students[i].getNum() + " " + students[i].getGrade());
			System.out.println();
		}
	}

}